#ifndef PLAYUR_BUDDYLIST_H
#define PLAYUR_BUDDYLIST_H 1

#include <QString>
#include <QList>
#include <QMap>

#define IRC_STATIC
#include <IrcSession>

namespace Playur {

/*! Provides a way to connect to IRC channels and notify the client of
 * changes in the group. This class relies of the Qt Irc client.
 */
class BuddyList : public QObject
{
Q_OBJECT

public:
    /*! Constructs a new IRC client with the given configuration.
     * \param ident The IRC nick to use
     * \param addr The network address to give to other clients
     */
    BuddyList(const QString& ident, const QString& addr);

    /*! Returns the list of available contacts. */
    const QMap<QString, QString> get();

signals:
    /*! Emitted when a contact connects.
     * \param nick Nickname of the contact
     */
    void buddyConnected(const QString& nick);

    /*! Emitted when a contact disconnects.
     * \param nick Nickname of the contact
     */
    void buddyDisconnected(const QString& nick);

private slots:
    void connected();
    void msgJoined(const QString&, const QString&);
    void msgParted(const QString&, const QString&, const QString&);
    void msgQuit(const QString&, const QString&);
    void msgMessageReceived(const QString&, const QString&, const QString&);
private:
    QString nick;
    QString server;
    QString address;
    QMap<QString, QString> addresses;
    Irc::Session* session;
};

} // Playur

#endif

